# !/usr/bin python3
# encoding: utf-8 -*-
# @file     : dubbo_study.py
# @author   : 沙陌 Matongxue_2
# @Time     : 2023/8/10 21:42
# @Copyright: 北京码同学
from dubbo.client import DubboClient
from dubbo.codec.encoder import Object

market = DubboClient(
    interface='cn.testfan.dubbo.service.MarketService',
    host='82.156.77.202:20880',
    dubbo_version='2.6.2',
    version='1.0'
)
# 调用抽奖接口，第一个参数是活动id，第二个参数是用户id
res = market.call('lottery',(2,10002))
print(res)

# 调用积分兑换接口，该接口的参数一个对象
exchangeRequest = Object(
    'cn.testfan.dubbo.model.ExchangeRequest',
    values={
        "userId":10001,
        "activityId":1,
        "awardId":4,
        "exchangeNum":1
    }
)
res = market.call('exchange',(exchangeRequest))
print(res)